package Stream.test1;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

public class IOSteam {

    //流读取文件
    public static void main(String[] args) {
        Path path = Paths.get("src/Stream/test1/file.txt");
        //带资源的try语句（try-with-resource）
        //try块退出时，会自动调用close()方法，关闭资源。
        try (Stream<String> lines = Files.lines(path)) {
            lines.forEach(System.out::println);
        } catch (IOException e) {
            e.getStackTrace();
        }


    }
}
